import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Set;

public class ContentModificado {

	public static void main(String[] args) {

		HashMap<Integer, String> dicionario = new HashMap<Integer, String>();

		BufferedReader br;
		try {
			br = new BufferedReader(new FileReader("cora.content"));

			String sCurrentLine;
			while ((sCurrentLine = br.readLine()) != null) {

				String[] cities = sCurrentLine.split("\t");
				dicionario.put(Integer.parseInt(cities[0]),
						cities[cities.length - 1]);
			}

			br.close();

			Set<Integer> keys = dicionario.keySet();

			ArrayList<Integer> array = new ArrayList<Integer>(keys);

			Collections.sort(array);

			BufferedWriter bw = new BufferedWriter(new FileWriter(
					"Resultados\\cora.content1"));

			for (int i = 0; i < array.size(); i++) {

				bw.write(array.get(i) + "\t" + dicionario.get(array.get(i))
						+ "\n");

				// System.out.println(array.get(i) + " \t "+
				// dicionario.get(array.get(i)));

			}

			bw.close();

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
